home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group99a.txt / 000205_icon-group-sender _Mon Oct 4 08:42:18 1999.msg < prev    next >
Internet Message Format  |  2000-09-20  |  3KB

  1. Return-Path: <icon-group-sender>
  2. Received: (from root@localhost)
  3.     by baskerville.CS.Arizona.EDU (8.9.1a/8.9.1) id IAA00712
  4.     for icon-group-addresses; Mon, 4 Oct 1999 08:42:09 -0700 (MST)
  5. Message-Id: <199910041542.IAA00712@baskerville.CS.Arizona.EDU>
  6. X-Authentication-Warning: agate-ether.berkeley.edu: news set sender to <news> using -f
  7. From: luvisi@andru.sonoma.edu
  8. X-Newsgroups: comp.lang.icon
  9. Subject: Re: A small puzzle
  10. Date: 02 Oct 1999 15:23:04 -0700
  11. To: Steve Wampler <sbw@tapestry.tucson.az.us>
  12. X-Newsreader: Gnus v5.3/Emacs 19.34
  13. To: icon-group@optima.CS.Arizona.EDU
  14. Errors-To: icon-group-errors@optima.CS.Arizona.EDU
  15. Status: RO
  16.  
  17. Steve Wampler <sbw@tapestry.tucson.az.us> writes:
  18. [snip]
  19. >    Write an Icon program to generate the pairings in a round-robin
  20. >    tournament.  The program should accept the player names as
  21. >    command line arguments (see the example below).
  22. [snip]
  23.  
  24. Here's my attempt:
  25.  
  26. procedure main()
  27.  every gameset := turnament(["a","b","c","d","e"])
  28.   do every write((left((pair := !gameset)[1], 5) || left(pair[2], 5)) | "");
  29.  every gameset := turnament(["a","b","c","d","e","f"])
  30.   do every write((left((pair := !gameset)[1], 5) || left(pair[2], 5)) | "");
  31. end
  32.  
  33. procedure turnament(people)
  34.  local i;
  35.  local stationary_player, gameset;
  36.  
  37.  stationary_player := (*people % 2 = 0 & get(people)) | "Buy";
  38.  every 1 to *people do {
  39.    gameset := [ [ stationary_player, people[*people] ] ];
  40.    every gameset |||:= [[people[ i := 1 to (*people - 1) / 2 ], people[-i-1]]];
  41.    suspend gameset;
  42.    push(people, pull(people));
  43.  }
  44.  fail;
  45. end
  46.  
  47. [snip]
  48. > (As an additional challenge, implement an optional -n argument, where
  49. > n is the number of courts - this is as much an exercise in determining
  50. > a reasonable policy for handling the pairing overfow as it is an
  51. > exercise in Icon programming.)
  52. [snip]
  53.  
  54. hm... it seems the hardest part would be when at the end of a virtual
  55. match, finding the pairs in the next virtual match that don't contain
  56. anybody who's playing in the curent physical match...
  57.  
  58. Andru
  59. -- 
  60. -------------------------------------------------------------------------- 
  61. | Andru Luvisi                 | http://libweb.sonoma.edu/         |
  62. | Programmer/Analyst           |   Library Resources Online              | 
  63. | Ruben Salazar Library        |-----------------------------------------| 
  64. | Sonoma State University      | http://www.belleprovence.com/         |
  65. | luvisi@andru.sonoma.edu      |   Textile imports from Provence, France |
  66. --------------------------------------------------------------------------
  67.